Mutex Class

A type of CriticalSection that has operating system-wide scope and is visible to other REALbasic applications.

Events

None

Properties

None

Methods

None

More information available in parent classes: CriticalSection:Object


Constructor

NameParametersDescription
Mutex Name as String The parameter is the name of the Mutex. If you pass an empty string, the Mutex will be identical to a CriticalSection; it will not be visible to other applications. If you pass a name, you can use the name to access the Mutex.


Notes

Mutex is short for Mutual Exclusion object. It allows several applications to share the same resource, but not simultaneously. The suggested usage of a Mutex is to create a Mutex with a unique name when the application launches. When the application needs to use the resource, it calls the Enter or TryEnter methods and calls the Leave method when it is finished. The most common use of a Mutex is to determine whether another instance of your application is currently running. You create a named Mutex in the application's open event and then check to see if you can get a lock on it. If the lock fails, then you know there's another instance of your application running. You can also use Mutexes to work with resources that are shared between applications (such as a serial port, printer, or some other system device).

You can call Enter or TryEnter multiple times in the same way as with a CriticalSection, including recursive calls.


See Also

Application, CriticalSection, Semaphore, Thread classes.